#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project  : ecshop-gitee
# @File     : page_ecshop_view_oder.py
# @Author   : LiuLei
# @Time     : 2021/7/3 1:07
# 调用by
from selenium.webdriver.common.by import By


class PageEcshopBackViewOder():
    """
    1.进入后台页面；
    2.点击查看订单
    3.点击生成发货单
    4.点击发货
    5.进入前台查询订单状态
    """

    def __init__(self, driver):
        self.driver = driver

        # 点击查看商品详情
        self.loc_ecshop_view = (By.XPATH, '//div[@id="listDiv"]/table[1]/tbody/tr[3]/td[7]/a')
        self.loc_back_search_order_word = (By.ID, 'user_name')
        self.loc_back_search_submit = (By.ID, "query")
        self.loc_back_search_assert = (By.XPATH, '//div[@id="listDiv"]/table[1]/tbody/tr[3]/td[2]')

    def back_ecshop_view(self):
        # 点击查看订单
        self.driver.find_element(*self.loc_ecshop_view).click()

    def back_ecshop_view_oder(self):
        self.back_ecshop_view()

    def back_search_order_word(self, word):
        self.driver.find_element(*self.loc_back_search_order_word).send_keys(word)

    def back_search_submit(self):
        self.driver.find_element(*self.loc_back_search_submit).click()

    def back_search_assert(self):
        actual = self.driver.find_element(*self.loc_back_search_assert).text
        return actual

    def search_order(self, word):
        self.back_search_order_word(word)
        self.back_search_submit()
        actual = self.back_search_assert()
        return actual
